package com.junyu.interceptor;

import com.junyu.pojo.entity.User;

/**
 * ThreadLocal工具类
 */
public class ThreadLocalUtil {
    public static final ThreadLocal<User> threadLocal = new ThreadLocal<>();

    /**
     * 添加ThreadLocal中的值
     * @param user 用户对象
     */
    public static void set(User user) {
        threadLocal.set(user);
    }

    /**
     * 获取ThreadLocal中的值
     */
    public static User get() {
        return threadLocal.get();
    }

    /**
     * 删除ThreadLocal中的值
     */
    public static void remove() {
        threadLocal.remove();
    }
}